package com.cat.dataStructure02;

/**
 * @author 曲大人的喵
 * @description https://leetcode.cn/problems/number-of-laser-beams-in-a-bank/?envType=daily-question&envId=2025-10-27
 * @create 2025/10/27 11:20
 * @since JDK17
 */

public class Solution68 {
    public int numberOfBeams(String[] bank) {
        int ans = 0, n = bank.length, m = bank[0].length();
        int[] cnt = new int[n];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                cnt[i] += bank[i].charAt(j) - '1';
            }
        }
        for (int i = 0; i < n; i++) {
            for (int j = i + 1; j < n; j++) {
                ans += cnt[i] * cnt[j];
                if (cnt[j] > 0) {
                    break;
                }
            }
        }

        return ans;
    }
}
